function parseQueryString(type) {
  var url = location.search;
  if (type === 'hash') {
    url = location.hash.substring(location.hash.indexOf("?"));
  }
  var query = {};
  if (url.indexOf("?") !== -1) {
    var str = url.substr(1);
    var strs = str.split("&");
    for (var i = 0; i < strs.length; i++) {
      query[strs[i].split("=")[0]] = decodeURIComponent(strs[i].split("=")[1]);
    }
  }
  return query;
}

function isValidIP(ip) {
  var reg = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/
  return reg.test(ip);
}

function IEVersion() {
  var userAgent = navigator.userAgent;
  var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1;
  var isEdge = userAgent.indexOf("Edge") > -1 && !isIE;
  var isIE11 = userAgent.indexOf("Trident") > -1 && userAgent.indexOf("rv:11.0") > -1;
  if (isIE) {
    var userAgent = navigator.userAgent;
    var reIE = new RegExp("MSIE (\\d+\\.\\d+);");
    reIE.test(userAgent);
    var fIEVersion = parseFloat(RegExp["$1"]);
    return fIEVersion
  } else {
    if (isEdge) {
      return "edge"
    } else {
      if (isIE11) {
        return 11
      } else {
        return -1
      }
    }
  }
}
var browser = {
  versions: function () {
    var u = navigator.userAgent;
    return {
      trident: u.indexOf("Trident") > -1,
      presto: u.indexOf("Presto") > -1,
      webKit: u.indexOf("AppleWebKit") > -1,
      gecko: u.indexOf("Firefox") > -1,
      mobile: !!u.match(/AppleWebKit.*Mobile.*/),
      ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),
      android: u.indexOf("Android") > -1 || u.indexOf("Linux") > -1,
      iPhone: u.indexOf("iPhone") > -1,
      iPad: u.indexOf("iPad") > -1,
      webApp: u.indexOf("Safari") > -1
    }
  }(),
  info: function () {
    var obj = {
      name: "unknown",
      version: 0
    };
    var msie = IEVersion();
    if (msie != -1) {
      obj = {
        name: "msie",
        version: msie
      }
    } else {
      var userAgent = navigator.userAgent.toLocaleLowerCase();
      if (/(chrome|firefox|opera|netscape)\D+(\d[\d.]*)/.test(userAgent)) {
        obj[RegExp.$1] = true;
        obj.name = RegExp.$1;
        obj.version = RegExp.$2
      } else {
        if (/version\D+(\d[\d.]*).*safari/.test(userAgent)) {
          obj.safari = true;
          obj.name = "safari";
          obj.version = RegExp.$2
        }
      }
    }
    return obj
  }()
};

if (browser.info.name == "msie") {
  location.href = "/html/browser.html";
}

if (!browser.versions.mobile) {
  document.querySelector("html").classList.add("pc");
} else {
  document.querySelector("html").classList.add("mobile");
}